import sun.applet.Main;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2022-06-28
 * Time: 19:56
 */
public class Test {
    public static void main(String[] args) {
        String str="we%are%happy";
        String ret=str.replaceAll("%"," ");
        System.out.println(ret);
    }
    public static void main18(String[] args) {

            String str = "abcdef";
            String ret = str.substring(1,4);//[1,4)//字符串截取
            System.out.println(ret);
            System.out.println("=============");
            String s = "    we are happy    ";
            System.out.println(s.trim());//当前字符串的左右的空格去掉
            System.out.println(s);


    }

    public static void main16(String[] args) {
        String str = "197\\168\\1\\1";
        String[] ret = str.split("\\\\");
        for (String s : ret) {
            System.out.println(s);
        }
    }

    public static void main17(String[] args) {
        String str = "192.168.1.1";
        String[] ret = str.split("\\.",4);
        for (String s : ret) {
            System.out.println(s);
        }
    }

    public static void main15(String[] args) {

            String s1 = "hello wyb happy everyday";
            String[] ret = s1.split(" ",4);//以空格的形式分开，分成4组
            for (String s : ret) {
                System.out.println(s);//打印
            }
        }

    public static void main14(String[] args) {

            String s1 = "ababcabcdabcde";

            String ret = s1.replaceFirst("ab","qquuuuu");//代表用qquuuuu替换ab
            System.out.println(ret);

            System.out.println("s1->  "+s1);//就算替换，但是它本身是没有改变的
        }

    public static void main13(String[] args) {

            String s = String.format("%d-%d-%d", 2003 ,2,14);
            System.out.println(s);
        }



    public static void main12(String[] args) {
     String s = "happy";
// 字符串转数组
     char[] ch = s.toCharArray();
    for (int i = 0; i < ch.length; i++) {
     System.out.print(ch[i]);
 }
  System.out.println();
// 数组转字符串
  String s2 = new String(ch);
    System.out.println(s2);
    }
    public static void main11(String[] args) {

            String s1 = "abondon";
            String ret = s1.toUpperCase();
            System.out.println(ret);
            System.out.println("s1-> " + s1);
            String s2 = "ABANDON";
            ret = s2.toLowerCase();
            System.out.println(ret);
    }
    public static void main10(String[] args) {
        int a = Integer.valueOf("64");//6*8^1 + 4*8^0 = 52//默认十进制
        System.out.println(a);
        int a2 = Integer.parseInt("100");//默认十进制
        System.out.println(a2);
    }
    public static void main9(String[] args) {
        //字符串转数字
        int data1 = Integer.parseInt("199785");
    double data2 = Double.parseDouble("1997.85");
    System.out.println(data1);
    System.out.println(data2);
    }
    public static void main8(String[] args) {
        //把其他的数据类型 变成字符串
        String s = String.valueOf(123);
        String s2 = String.valueOf(12.5);
        System.out.println(s);
        System.out.println(s2);
    }
    public static void main7(String[] args) {

String s = "aaabbbcccaaabbbccc";
System.out.println(s.charAt(3)); // 'b'
System.out.println(s.indexOf('c')); // 6
System.out.println(s.indexOf('c', 10)); // 15
System.out.println(s.indexOf("bbb")); // 3
System.out.println(s.indexOf("bbb", 10)); // 12
System.out.println(s.lastIndexOf('c')); // 17
System.out.println(s.lastIndexOf('c', 10)); // 8
System.out.println(s.lastIndexOf("bbb")); // 12
System.out.println(s.lastIndexOf("bbb", 10));// 3
    }
    public static void main6(String[] args) {
        String s1 = new String("WYB");
        String s2 = new String("wyb");
        System.out.println(s1.compareToIgnoreCase(s2));//0
    }
    public static void main5(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = new String("world");

        System.out.println(s1 == s2);   // false
        System.out.println(s1.equals(s2));//true


        System.out.println(s2 == s3);   // false
        System.out.println(s2.equals(s3)); // false
        System.out.println(s1.compareTo(s2));

    }
    public static void main4(String[] args) {
        String s1=new String("wyb");
        String s2=new String("wyb");
        System.out.println(s1==s2);//false
    }
    public static void main3(String[] args) {
        int a = 40;
        int b = 20;
        int c = 40;

System.out.println(a == b); // false
System.out.println(a == c); // true
    }
    public static void main2(String[] args) {

// s1和s2引用的是不同对象 s1和s3引用的是同一对象
        String s1 = new String("hello");
        String s2 = new String("world");
        String s3 = s1;
        System.out.println(s1.length());
        System.out.println(s1.isEmpty());
    }

        public static void main1(String[] args){
            String string = "hello";
            String ret = new String("wyb520");


            char[] ch = {'a', 'b', 'c'};
            String str = new String(ch);
        }

}
